#include<bits/stdc++.h>
using namespace std;

int t,n,m,l,v,b[200000],a[200000],x[200000],ans1,ans2;

struct node{
    int len,l;
}cc[200000];
vector<int>ch[200000];
struct car{
    int start_speed,add_speed,dis,l,r;
}c[200000];
bool cmp(node a,node b){
    if(a.len==b.len)return a.l<b.l;
    return a.len<b.len;
}
void dfs(int x,int l,int r){
    if(l==1&&r==n){
        ans2=min(ans2,x);
        return ;
    }
    for(int i=m;i>=1;i--){
        if(b[i])continue;
        b[i]=1;
        dfs(x+1,min(l,cc[i].l),max(r,cc[i].l+cc[i].len-1));
        b[i]=0;
    }

}
int main(){
    //freopen("detect.in","r",stdin);
    //freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>v;
        memset(x,0,sizeof x);
        memset(b,0,sizeof b);
        for(int i=1;i<=n;i++){
            cin>>c[i].dis>>c[i].start_speed>>c[i].add_speed;
            if(c[i].add_speed>0){
                c[i].l=(v*v-c[i].start_speed*c[i].start_speed)/2.0/c[i].add_speed;
                c[i].r=l;
            }
            else if(c[i].add_speed<0){
                c[i].r=(v*v-c[i].start_speed*c[i].start_speed)/2.0/c[i].add_speed;
                c[i].l=c[i].dis;
            }
            else{
                if(c[i].start_speed>v)c[i].l=c[i].dis,c[i].r=l;
            }
        }
        for(int i=1;i<=m;i++){
            cin>>a[i];
        }
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(a[i]<=c[j].r&&a[i]>=c[j].l){
                    ch[j].push_back(i);
                    if(!x[j])ans1++;
                    x[j]=1;
                }
            }
        }
        ans2=m;
        cout<<++ans1<<' ';
        for(int i=1;i<=m;i++){
            bool flag=0;
            for(int j=1;j<=n;j++){
                if(int(ch[j].size())==1&&ch[j][0]==i){
                    flag=1;
                }
            }
            if(!flag){
                ans2--;
                for(int j=1;j<=n;j++){
                    int g=0;
                    for(int k=0;k<ch[j].size();k++){
                        g=k;
                        if(ch[j][k]==i)break;
                    }
                    for(int k=g;k<ch[j].size()-1;k++)ch[k]=ch[k+1];
                }
            }
        }
        cout<<ans2<<endl;

    }
    return 0;
}
